home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Examples / Text / Textension / Include / Pages.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-21  |  5.2 KB  |  211 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Pages.h
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    Essam Zaky
  7.  
  8.     Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <3>      1/5/94    EZ        don't compile if txtnMultiFrames compilation var is not defined
  13.          <2>      1/4/94    EZ        clean up
  14.          <1>      1/4/94    EZ        first checked in
  15.  
  16. */
  17.  
  18. #ifdef txtnMultiFrames
  19.  
  20. #ifndef _Pages_
  21. #define _Pages_
  22.  
  23. #ifndef _ToolBoxDump_
  24. #include "ToolBoxDump.h"
  25. #endif
  26.  
  27. #ifndef _TextensionCommon_
  28. #include "TextensionCommon.h"
  29. #endif
  30.  
  31. #ifndef _Array_
  32. #include "Array.h"
  33. #endif
  34.  
  35. #ifndef _Frames_
  36. #include "Frames.h"
  37. #endif
  38.  
  39. #ifndef _FrameFormatter_
  40. #include "FrameFormatter.h"
  41. #endif
  42.  
  43. //***************************************************************************************************
  44.  
  45. const short kPageGutter = 5;
  46.  
  47. class CPageFrames : public CMonoSizeFrames {
  48. public:
  49.     CPageFrames();
  50.     
  51.     void IPageFrames();
  52.     
  53.     //•override
  54.     
  55.     virtual void SectFrames(const Rect* theRect, CSectFrames* sectedFrames) const;
  56.     
  57.     
  58.     #ifdef txtnScal
  59.     virtual void GetAbsTextFrame(long frameNo, TxtnLongRect* absRect, Boolean scaled = true) const;
  60.  
  61.     virtual void GetAbsFrameRect(long frameNo, TxtnLongRect* theRect, Boolean scaled = true) const;
  62.     #else
  63.     virtual void GetAbsTextFrame(long frameNo, TxtnLongRect* absRect) const;
  64.  
  65.     virtual void GetAbsFrameRect(long frameNo, TxtnLongRect* theRect) const;
  66.     #endif
  67.     
  68.     virtual long GetTotalHite() const;
  69.     virtual long GetTotalWidth() const;
  70.     
  71.     //•own members
  72.     inline short GetCountRowPages() {return fRowPages;}
  73.     void SetCountRowPages(short newCount, CDisplayChanges* changes = nil);
  74.  
  75.     virtual long GetCountPages() const;
  76.             
  77.     virtual long Point2Frame(const LongPoint* thePt) const;
  78.     //up to now, always return a value >= 0
  79.  
  80.     void PageNo2Cell(long frameNo, TCell* cell) const;
  81.     
  82. protected:
  83.     short fRowPages;
  84.     
  85.     //•override
  86.     virtual void CreateFrameFormatter();
  87.  
  88.     //•own members
  89.     #ifdef txtnScal
  90.     long GetPageHite(Boolean scaled = true) const; //scaled, without gutter
  91.     long GetPageWidth(Boolean scaled = true) const; //scaled, without gutter
  92.     #else
  93.     long GetPageHite() const; //scaled, without gutter
  94.     long GetPageWidth() const; //scaled, without gutter
  95.     #endif
  96.     
  97.     short Flip(short indexInRow, short countInRow, char direction) const;
  98.     
  99.     virtual short GetPageGutter() const; //returns kPageGutter, never scaled
  100.     
  101.     
  102. private:
  103. };
  104. //*************************************************************************************************
  105.  
  106.  
  107. //array element for fFramesLines
  108. struct TFrameLines {
  109.     long lastLine;
  110.     short linesHite; //non scaled
  111. };
  112. typedef TFrameLines* TFrameLinesPtr;
  113.  
  114. class CMultiFrameFormatter : public CFrameFormatter {
  115.     public:
  116.         CMultiFrameFormatter();
  117.         
  118.         void IMultiFrameFormatter();
  119.         
  120.         //•override
  121.         virtual void Free();
  122.         virtual void FreeData();
  123.         virtual void Compact();
  124.  
  125.         virtual void SetFrameHite(long frameNo, short newHite) = 0;
  126.         virtual short GetFrameHite(long frameNo) const = 0; //non scaled
  127.         
  128.         virtual OSErr InsertLine(const TLineHiteInfo* lineHiteInfo, CFormatReflowLines* formatReflowLines,
  129.                                                             long lineNo = -1);
  130.         virtual OSErr SetLineHiteInfo(const TLineHiteInfo* lineHiteInfo, long lineNo
  131.                                                                 , CFormatReflowLines* formatReflowLines);
  132.         virtual void RemoveLines(long countLines, long lineNo, CFormatReflowLines* formatReflowLines);
  133.         
  134.         virtual OSErr ForceOverflow(long lineNo);
  135.         
  136.         virtual Boolean GetFrameLineRange(long frameNo, TOffsetPair* frameLines) const;
  137.         virtual long Line2Frame(TOffset offset) const;
  138.             
  139.         virtual long GetCountFrames() const;
  140.  
  141.         #ifdef txtnScal
  142.         virtual long GetFrameTextHite(long frameNo, Boolean scaled = true) const;
  143.         #else
  144.         virtual long GetFrameTextHite(long frameNo) const;
  145.         #endif
  146.     
  147.     protected:
  148.         CRanges* fFramesLines; //TFrameLines array
  149.         
  150.         Boolean fCheckReflow;
  151.         
  152.         //•override
  153.         
  154.         
  155.         //•own members
  156.         virtual Boolean VariableSizeFrames() const;
  157.         
  158.         OSErr CheckReflow(long frameNo, CFormatReflowLines* formatReflowLines
  159.                                             , Boolean checkFrameBefore =false
  160.                                             , short pixReflow =0, const TOffsetPair* linesReflow=nil);
  161.         
  162.         virtual Boolean MeasureFrame(long frameNo, short* pixReflow, long* newFrameEnd
  163.                                                                     , TOffsetPair* linesReflow);
  164.                                                                                         
  165.         virtual Boolean BreakFrame(long frameNo, short* pixReflow, TOffsetPair* linesReflow
  166.                                                             , CFormatReflowLines* formatReflowLines);
  167.                                                             
  168.         virtual OSErr AppendFrame(short framePix, long lastLine =-1);
  169.  
  170.         void RemoveFrames(long count, long frameNo);
  171.         
  172.         #ifdef txtnDebug
  173.         void CheckFramesLines();
  174.         #endif
  175.         
  176.         
  177.     private:
  178.         void RemoveFrameLines(long frameNo, long firstLine, long lastLine);
  179.         
  180.         long RemoveFormattedFrames(long frameNo, short* pix2Remove, TOffsetPair* lines2Remove);
  181. };
  182. //*************************************************************************************************
  183.  
  184. class CPageFormatter : public CMultiFrameFormatter { //multi frame formatter with fixed size frame
  185.     public:
  186.         CPageFormatter();
  187.         
  188.         void IPageFormatter();
  189.         
  190.         //•override
  191.         virtual void SetFrameHite(long frameNo, short newHite);
  192.         virtual short GetFrameHite(long frameNo) const;
  193.  
  194.         virtual OSErr Format();
  195.  
  196.         //•own members
  197.     
  198.     protected:
  199.         //•override
  200.  
  201.         //•own members
  202.         
  203.     private:
  204.         short fPageHite;
  205. };
  206. //*************************************************************************************************
  207.  
  208. #endif //_Pages_
  209.  
  210.  
  211. #endif //txtnMultiFrames